﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace ObjectOuster
{
    public partial class MainPage : UserControl
    {
        private void MakeMoveCallback(int theColumn,int theRow)
        {
            GameConfig.SoundEffects.Play(SoundEffect.MakeMove);
            titleBar.UpdateScores();
            rightBar.ShowMovesLeft();
            gridBoard.RenderBoard();
            GameData.Board.HighlightedRegion = GameData.Board[theColumn][theRow].Region;
        }
        private void NewGameCallback()
        {
            gridBoard.RenderBoard();
            rightBar.ShowMovesLeft();
            titleBar.UpdateScores();
        }
        private void CurrentThemeChangedCallback()
        {
            gridBoard.RenderBoard();
        }
        private void UndoMoveCallback()
        {
            gridBoard.RenderBoard();
            rightBar.ShowMovesLeft();
            titleBar.UpdateScores();
        }
        public MainPage()
        {
            GameData.OnMakeMove += MakeMoveCallback;
            GameData.OnNewGame += NewGameCallback;
            GameData.OnUndoMove += UndoMoveCallback;
            GameConfig.OnCurrentThemeChanged += CurrentThemeChangedCallback;
            InitializeComponent();
            GameData.NewGame();
            gridBoard.RenderBoard();
            rightBar.ShowMovesLeft();
        }

        private void music1_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.Music[Music.Music1] = music1;
        }

        private void music2_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.Music[Music.Music2] = music2;
        }

        private void music3_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.Music[Music.Music3] = music3;
        }

        private void music4_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.Music[Music.Music4] = music4;
        }

        private void music5_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.Music[Music.Music5] = music5;
        }

        private void music6_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.Music[Music.Music6] = music6;
        }

        private void makeMoveSound_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.SoundEffects[SoundEffect.MakeMove] = makeMoveSound;
        }

        private void noMovesSound_DownloadProgressChanged(object sender, RoutedEventArgs e)
        {
            GameConfig.SoundEffects[SoundEffect.NoMovesLeft] = noMovesSound;
        }


    }
}
